package com.tpc.control.util;

import java.util.List;
import java.util.Vector;

import javax.faces.model.SelectItem;

import com.tpc.control.jpa.Division;
import com.tpc.control.jpa.DivisionDAO;
import com.tpc.control.jpa.Status;
import com.tpc.control.jpa.StatusDAO;
import com.tpc.control.jpa.Uom;
import com.tpc.control.jpa.UomDAO;

public class GenerateList {
	public static Vector generateDivisionSelectItems() {
		Vector divisionList = new Vector();
		DivisionDAO dao = new DivisionDAO();
		List<Division> divisions = dao.findAll();
		SelectItem itemNull = new SelectItem(null, "");
		divisionList.addElement(itemNull);
		for(int i=0;i<divisions.size();i++) {
			Division division = divisions.get(i);
			SelectItem item = new SelectItem(division.getDivision(), division.getDivisionName());
			divisionList.addElement(item);
		}
		return divisionList;
	}
	
	public static Vector generateReserveStatusSelectItems() {
		Vector statusList = new Vector();
		StatusDAO dao = new StatusDAO();
		List<Status> statuses = dao.findByStatusType("RESERVE");
		SelectItem itemNull = new SelectItem(null, "");
		statusList.addElement(itemNull);
		for(int i=0;i<statuses.size();i++) {
			Status aStatus = statuses.get(i);
			SelectItem item = new SelectItem(aStatus.getId().getStatusCode(), aStatus.getStatusName());
			statusList.addElement(item);
		}
		return statusList;
	}
	
	public static Vector generateUOMSelectItems() {
		Vector uomList = new Vector();
		UomDAO dao = new UomDAO();
		List<Uom> uoms = dao.findAll();
		SelectItem itemNull = new SelectItem(null, "");
		uomList.addElement(itemNull);
		for(int i=0;i<uoms.size();i++) {
			Uom aUom = uoms.get(i);
			SelectItem item = new SelectItem(aUom.getUomId(), aUom.getUomName());
			uomList.addElement(item);
		}
		return uomList;
	}
}
